from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database.models import Base
import os

# PostgreSQL 连接配置
POSTGRES_URI = "postgresql://zhuohua:hx201954@localhost:5432/test_db"

# MySQL 连接配置 (用于日志和会话数据)
MYSQL_URI = "mysql+pymysql://root:hx201954@120.26.117.78:3306/smart_official_logs"

# 创建PostgreSQL引擎
postgres_engine = create_engine(POSTGRES_URI)
PostgresSession = sessionmaker(bind=postgres_engine)

# 创建表
def init_database():
    Base.metadata.create_all(postgres_engine)
    print("数据库表创建完成")

def get_postgres_session():
    return PostgresSession()
